﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartForm.Rule
{
    /// <summary>
    /// 大表单信息
    /// </summary>
    public class BigForm
    {
        /// <summary>
        /// 网上办事大厅用户登录token
        /// </summary>
        public string LoginToken { get; set; }

        /// <summary>
        /// 办事指南分类 - 如论文提交系统、自考学生报名系统
        /// </summary>
        public string TypeId { get; set; }

        /// <summary>
        /// 智能填写的第三方系统标识
        /// </summary>
        public List<string> SystemIds { get; set; }

        /// <summary>
        /// 表单项列表
        /// </summary>
        public List<FormOption> FormOptionList { get; set; }

    }

    /// <summary>
    /// 大表单选项键值
    /// </summary>
    public class FormOption
    {
        /// <summary>
        /// 表单项 - 标题（便于人为识别）
        /// </summary>
        public string Title { get; set; }
        /// <summary>
        /// 表单项 - 名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 表单项 - 值
        /// </summary>
        public string Value { get; set; }
        /// <summary>
        /// 输入类型
        /// </summary>
        public InputType InputType { get; set; }
    }

    public enum InputType
    {
        /// <summary>
        /// 文本类型
        /// </summary>
        Text = 0,
        /// <summary>
        /// 文件类型
        /// </summary>
        File = 1
    }


    public enum SystemWebBrowserType
    {
        /// <summary>
        /// ie浏览器
        /// </summary>
        IE = 0,
        /// <summary>
        /// Chrome浏览器
        /// </summary>
        Chrome = 1
    }

    /// <summary>
    /// 第三方系统规则
    /// </summary>
    public class SystemRule
    {
        /// <summary>
        /// 规则id
        /// </summary>
        public string ID { get; set; }
        /// <summary>
        /// 平台：微博，微信等
        /// </summary>
        public string Platform { get; set; }
        /// <summary>
        /// 系统名称
        /// </summary>
        public string SystemName { get; set; }
        /// <summary>
        /// 系统ID
        /// </summary>
        public string SystemId { get; set; }
        /// <summary>
        /// 登录url
        /// </summary>
        public string LoginUrl { get; set; }
        /// <summary>
        /// 登录账户
        /// </summary>
        public string Account { get; set; }
        /// <summary>
        /// 密码
        /// </summary>
        public string Password { get; set; }

        /// <summary>
        /// 登录JS组，语法词：账户：$account，密码：$password
        /// </summary>
        public List<ExecuteJS> LoginJS { get; set; }

        /// <summary>
        /// 类型
        /// </summary>
        public string TypeId { get; set; }

        /// <summary>
        /// 需要执行的表单项元素
        /// </summary>
        public List<FormOptionJS> FormOptionJSList { get; set; }
    }

    /// <summary>
    /// 执行js
    /// </summary>
    public class ExecuteJS
    {
        /// <summary>
        /// js内容
        /// </summary>
        public string JS { get; set; }
        /// <summary>
        /// 延迟执行
        /// </summary>
        public int Second { get; set; }
    }

    /// <summary>
    /// 具体系统执行 - 表单选项JS
    /// </summary>
    public class FormOptionJS
    {
        /// <summary>
        /// 表单项 - 名称（匹配大表单中的选项）
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 表单项 - 值（根据大表单转义编码后的值）
        /// </summary>
        public string Value { get; set; }
        /// <summary>
        /// 表单填充执行的js，语法词：值：$value
        /// </summary>
        public string JS { get; set; }
        /// <summary>
        /// 延迟执行
        /// </summary>
        public int Second { get; set; }
        /// <summary>
        /// 提交项，需要用户收到确认事件；
        /// </summary>
        public bool Submit { get; set; }
        /// <summary>
        /// 整个任务完成标记 - 同一组任务操作只能出现一次
        /// </summary>
        public bool Completed { get; set; }

        public bool Paste = false;

        public string GetJS()
        {
            return JS.Replace("$value", Value);
        }
    }

}
